package com.github.linkoog.model_designer.ide.editer.dbmodel.right_editer;

import com.github.linkoog.model_designer.ide.editer.DBTableEditPanel;
import com.github.linkoog.model_designer.ide.editer.common.TableVo;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiManager;
import org.jetbrains.yaml.YAMLElementGenerator;
import org.jetbrains.yaml.psi.YAMLFile;

import javax.swing.*;
import java.awt.*;

public class DBTableEditDialog extends DialogWrapper {

    private final Project project;
    private final VirtualFile virtualFile;
    private final YAMLFile yamlFile;
    private final YAMLElementGenerator yamlElementGenerator;

    private JPanel myMainPanel;

    private DBTableEditPanel dbTableEditPanel;

    public DBTableEditDialog(Project project, VirtualFile virtualFile,TableVo tableVo){
        super(project,false);
        this.project = project;
        this.virtualFile = virtualFile;
        this.yamlFile = (YAMLFile) PsiManager.getInstance(project).findFile(virtualFile);
        this.yamlElementGenerator = YAMLElementGenerator.getInstance(project);

        dbTableEditPanel = new DBTableEditPanel(project, virtualFile, tableVo);
        myMainPanel.add(dbTableEditPanel.getMyMainPanel(), BorderLayout.CENTER);
        myMainPanel.setMinimumSize(new Dimension(960, 680));

        init();
    }

    public JPanel getMyMainPanel() {
        return myMainPanel;
    }

    @Override
    protected JPanel createCenterPanel() {
        return myMainPanel;
    }
}
